package demo

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func HttpDemo() {
	http.HandleFunc("/", echo)
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic(err)
	}
}

func echo(wr http.ResponseWriter, req *http.Request) {
	bytes, err := ioutil.ReadAll(req.Body)
	if err != nil {
		panic(err)
	}

	writeLen, err := wr.Write(bytes)
	if err != nil {
		panic(err)
	}
	fmt.Println("writeLen: ", writeLen)
}
